<template>
	<view class="content">
		<view class="info-box">
			<!-- <view class="head">基本信息</view> -->
			<view class="item column">
				<text class="label">产品单位</text>
				<text class="text">{{item.unit}}</text>
			</view>
			<view class="item column">
				<text class="label">产品名称</text>
				<text class="text">{{item.name}}</text>
			</view>
			<view class="item column">
				<text class="label">产品编码</text>
				<text class="text">{{item.code}}</text>
			</view>
			<view class="item column">
				<text class="label">价格</text>
				<text class="text">{{item.price}}</text>
			</view>
			<view class="item column">
				<text class="label">提成</text>
				<text class="text">{{item.rate}}</text>
			</view>
			<view class="item column">
				<text class="label">积分</text>
				<text class="text">{{item.integral}}</text>
			</view>
			<view class="item column">
				<text class="label">是否上架</text>
				
				<text class="text">
						{{utils.getDictLabelName("productStatus",item.status)}}
				</text>
			</view>
			<view class="item column" >
				<text class="label">描述</text>
				<rich-text :nodes="item.description"></rich-text>
			</view>
			
		</view>
		<!-- <view class="info-box">
			<view class="head">系统信息</view>
			<view class="item">
				<text class="label">创建人</text>
				<text class="text">admin</text>
			</view>
			<view class="item">
				<text class="label">创建时间</text>
				<text class="text">2021-03-14 18:45:54</text>
			</view>
			<view class="item">
				<text class="label">更新时间</text>
				<text class="text">2021-03-14 18:45:54</text>
			</view>
		</view> -->
	</view>
</template>

<script>
	
	export default {
		data() {
			return {
				content:'<div style="text-align:center;"><img src="https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-uni-app-doc/d8590190-4f28-11eb-b680-7980c8a877b8.png"/></div>',
				item:{},
			}
		},
		filters:{
			/**
			 * 处理富文本里的图片宽度自适应
			 * 1.去掉img标签里的style、width、height属性
			 * 2.img标签添加style属性：max-width:100%;height:auto
			 * 3.修改所有style里的width属性为max-width:100%
			 * 4.去掉<br/>标签
			 * @param html
			 * @returns {void|string|*}
			 */
			formatRichText (html) { //控制小程序中图片大小
				let newContent= html.replace(/<img[^>]*>/gi,function(match,capture){
					match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
					match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
					match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
					return match;
				});
				newContent = newContent.replace(/style="[^"]+"/gi,function(match,capture){
					match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi, 'max-width:100%;');
					return match;
				});
				newContent = newContent.replace(/<br[^>]*\/>/gi, '');
				newContent = newContent.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:inline-block;margin:10rpx auto;"');
				return newContent;
			}
		},
		onLoad() {
			// 修改顶部导航背景色
			uni.setNavigationBarColor({
				frontColor: '#ffffff',
				backgroundColor: '#39b54a',
				animation: {
					duration: 400,
					timingFunc: 'easeIn'
				}
			})
		},
		methods: {
			getProduct(data){
				this.item=data;
			},
			// 拨打电话
			callPhone(tel){
				uni.makePhoneCall({
					phoneNumber: tel
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.content{
		background: #fff;
		padding-bottom: 20upx;
		.info-box{
			.head{
				height: 60upx;
				line-height: 60upx;
				font-size: 32upx;
				color: #000;
				font-weight: bold;
				position: relative;
				padding: 10upx 50upx;
				// &::after{
				// 	content: "";
				// 	width: 10upx;
				// 	height: 10upx;
				// 	border-radius: 5upx;
				// 	background: #333;
				// 	position: absolute;
				// 	top: 50%;
				// 	transform: translateY(-50%);
				// 	left: 20upx;
				// }
			}
			.item{
				height: auto;
				line-height: 90upx;
				padding: 0 50upx;
				border-bottom: 1px solid #f7f7f7;
				&:last-child{
					border-bottom: none;
				}
				&.column{
					height: auto;
					display: flex;
					flex-direction: column;
					.text{
						margin-bottom: 20upx;
						line-height: 1.5;
					}
				}
				.label{
					font-size: 28upx;
					color: #999;
					margin-right: 30upx;
				}
				.text{
					font-size: 32upx;
					color: #000;
					&.blue{
						color: #2172FF;
					}
				}
			}
		}
	}
</style>
